import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

//查询模型列表
export const getModelList = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/model/query`, {
    data
  });
};
// 设备属性-查询列表接口
export const equipmentAttribute = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipmentAttribute/queryList`, {
    data
  });
};
// 设备属性-查询列表接口（新）
export const queryPointList = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/equipmentAttribute/queryPointList`, {
    data
  });
};
// 设备属性-动态属性点位值历史数据曲线图
export const getPositionNumGraph = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipmentAttribute/getPositionNumGraph`, {
    data
  });
};
// 设备属性-新增数据
export const saveEquipmentAttribute = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipmentAttribute/saveEquipmentAttribute`, {
    data
  });
};
// 设备属性-修改数据
export const updateEquipmentAttribute = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipmentAttribute/updateEquipmentAttribute`, {
    data
  });
};
// 设备属性-删除-禁用
export const delEquipmentAttribute = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipmentAttribute/delEquipmentAttribute`, {
    data
  });
};
// 设备属性-查询详情数据
export const getEquipmentAttribute = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipmentAttribute/getEquipmentAttribute`, {
    data
  });
};
// 指标-设备动态属性关闭可视化标签
export const closeVisualTag = (data?: object) => {
  return http.request("post", `/account/api/v1/publish/measure/closeVisualTag`, {
    data
  });
};
// 指标-设备动态属性打开可视化标签
export const openVisualTag = (data?: object) => {
  return http.request("post", `/account/api/v1/publish/measure/openVisualTag`, {
    data
  });
};

/**
 设备台账接口
 **/
// 查询设备系统模型树接口
export const queryEquipSystemModelTree = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/systemCategory/querySystemModelTree", {
    data
  });
};
// 查询设备台账接口
export const queryEquipLedger = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/equipment/queryList", {
    data
  });
};
// 查询设备台账接口
export const queryEquipIdLedger = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipment/getByEqpId", {
    data
  });
};

/**
 设备档案管理-设备列表
 **/
//查询单个设备
export const queryEqpById = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/equipment/queryByEqpId`, {
    data
  });
};
//删除设备
export const deleteEquipment = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/equipment/delete`, {
    data
  });
};
//新增设备
export const createEquipment = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipment/create`, {
    data
  });
};
//修改设备
export const updateEquipment = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/equipment/update`, {
    data
  });
};

// 设备列表-获取设备二维码文件
export const getEqpImgs = data => {
  return http.request<Array<any>>("post", "/digitaltwins/api/v1/equipment/queryFileIds", {
    data
  });
};

// 设备列表-批量生成设备二维码文件
export const batchCreateEqpImgs = data => {
  return http.request("post", "/digitaltwins/api/v1/equipmentQrCode/createQrCodeFile", {
    data
  });
};

// 获取系统下拉树
export const querySystemSelect = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/systemCategory/querySystemModelCondition`, {
    data
  });
};
// 设备型号下拉列表
export const getEquipModelSelect = (data?: object) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipmentModel/queryOptions`, {
    data
  });
};

// 查询设备手册/爆炸图/扩展文件列表--DMS
export const getDMSFileList = (data?: Record<string, any>) => {
  return http.request<Array<any>>("post", `/dms/api/v1/docApi/queryByIdList`, {
    data
  });
};

// 查询设备手册/爆炸图/扩展文件列表
export const getFileList = (data?: Record<string, any>) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipment/queryFileDTOByEqpId`, {
    data
  });
};

// pid图
export const savePid = (data?: Record<string, any>) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipment/updatePid`, {
    data
  });
};

// 设备手册
export const saveGuide = (data?: Record<string, any>) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipment/updateDocFile`, {
    data
  });
};

// 设备手册
export const saveSOP = (data?: Record<string, any>) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipment/updateSopFile`, {
    data
  });
};

// 设备图纸
export const saveBoomImg = (data?: Record<string, any>) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipment/updatePicFile`, {
    data
  });
};

/**
 基础设置-设备系统接口
 **/
// 查询设备系统接口
export const queryEquipSystem = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/systemCategory/queryListTree", {
    data
  });
};
// 新增设备系统接口
export const addEquipSystem = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/systemCategory/saveSystemCategory", {
    data
  });
};
// 编辑设备系统接口
export const editEquipSystem = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/systemCategory/updateSystemCategory", {
    data
  });
};
// 删除设备系统接口
export const deleteEquipSystem = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/systemCategory/delSystemCategory", {
    data
  });
};

/**
 基础设置-设备总称接口
 **/
// 查询设备总称接口
export const queryEquipName = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/equipmentCategory/queryList", {
    data
  });
};
// 新增设备总称接口
export const addEquipName = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentCategory/create", {
    data
  });
};
// 编辑设备总称接口
export const editEquipName = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentCategory/update", {
    data
  });
};
// 删除设备总称接口
export const deleteEquipName = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentCategory/delete", {
    data
  });
};
// 设备总称下拉列表
export const getEquipNameSelect = (data?: object) => {
  return http.request<Array<any>>("post", "/digitaltwins/api/v1/equipmentCategory/queryOptions", {
    data
  });
};
// 通过设备总称查询系统
export const queryListByCategoryId = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentCategory/queryListByCategoryId", {
    data
  });
};
// 删除设备总称关联系统
export const deleteCategorySystem = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentCategory/deleteSystem", {
    data
  });
};
// 新增设备总称关联系统
export const addCategorySystem = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentCategory/addSystem", {
    data
  });
};

/**
 基础设置-设备类型接口
 **/
// 查询设备类型接口
export const queryEquipType = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/equipmentType/queryListPage", {
    data
  });
};
// 新增/编辑设备类型接口
export const addEquipType = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentType/saveEquipmentType", {
    data
  });
};
// 删除设备类型接口
export const deleteEquipType = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentType/delEquipmentType", {
    data
  });
};
// 设备类型下拉列表
export const getEquipTypeSelect = (data?: object) => {
  return http.request<Array<any>>("post", `/digitaltwins/api/v1/equipmentType/queryOptions`, {
    data
  });
};

/**
 基础设置-设备型号接口
 **/
// 查询设备型号接口
export const queryEquipModel = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/equipmentModel/queryListPage", {
    data
  });
};
// 新增/编辑设备型号接口
export const addEquipModel = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentModel/saveEquipmentModel", {
    data
  });
};
// 删除设备型号接口
export const deleteEquipModel = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/equipmentModel/delEquipmentModel", {
    data
  });
};

/**
 设备备件清单接口
 **/
// 查询设备备件清单接口
export const querySpareParts = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/eqpSparePartInventory/queryListPage", {
    data
  });
};
// 获取设备备件清单接口
export const getSpareParts = (data?: Number) => {
  return http.request("post", `/digitaltwins/api/v1/eqpSparePartInventory/getEqpSparePartInventory/${data}`, {
    data
  });
};
// 新增/编辑设备备件清单接口
export const addSpareParts = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/eqpSparePartInventory/saveEqpSparePartInventory", {
    data
  });
};
// 删除设备备件清单接口
export const deleteSpareParts = (data?: Number) => {
  return http.request("post", `/digitaltwins/api/v1/eqpSparePartInventory/delEqpSparePartInventory/${data}`, {
    data
  });
};
// 根据备件分类编码集合获取备件信息
export const getSparePartsCode = data => {
  return http.request("post", "/digitaltwins/api/v1/sparePart/queryListByCategoryCodes", {
    data
  });
};
// 根据备件分类编码集合获取备件信息（新）
export const getSparePartsCodeNew = data => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/queryListByCategoryCodes", {
    data
  });
};
// 根据备件分类型号集合获取备件信息（新）
export const getSparePartsModelCodesNew = data => {
  return http.request("post", "/digitaltwins/api/v1/sparePartNew/queryListByModelCodes", {
    data
  });
};
// 备件台账信息-根据设备id获取备件信息
export const getSparePartsByEqpId = data => {
  return http.request("post", `/digitaltwins/api/v1/sparePart/queryListByEqpId/${data}`);
};
// 备件台账信息-根据设备id获取备件信息（新）
export const getSparePartsByEqpIdNew = data => {
  return http.request("post", `/digitaltwins/api/v1/sparePartNew/queryListByEqpId/${data}`);
};
// 设备关联设备仪表-查询设备关联设备仪表列表
export const queryEqpRelByEqpId = data => {
  return http.request("post", "/digitaltwins/api/v1/eqpRel/queryEqpRelByEqpId", {
    data
  });
};
// 设备关联设备仪表-新增设备关联设备仪表
export const saveEqpRelByEqpId = data => {
  return http.request("post", "/digitaltwins/api/v1/eqpRel/saveData", {
    data
  });
};
// 根据设备编号查询设备历史列表
export const getEquipHistoryList = data => {
  return http.request("post", "/digitaltwins/api/v1/equipment/queryHistoryListByEqpId", {
    data
  });
};
// 查询设备历史
export const getEquipHistory = data => {
  return http.request("post", "/digitaltwins/api/v1/equipment/queryHistoryById", {
    data
  });
};
